﻿CREATE PROCEDURE [dbo].[proc_CallCenter_Record_Create]
	(
		@ZuoxiID int,
		@Type nvarchar(50),
		@Tel nvarchar(50),
		@StartDate datetime,
		@EndDate datetime,
		@FileName nvarchar(50),
		@TxtFileName nvarchar(50),
		@CompanyId int
	)
AS
begin	
	Declare @n int
	Select @n=Count(Id) From CallCenter_Record Where FileName=@FileName
	if(@n<=0)
	begin
		Declare @DepartmentId int,@UserName nvarchar(50),@EName nvarchar(50)
		Select @DepartmentId=DepartmentId,@UserName=UserName,@EName=EName From CallCenter Where ZXNum=@ZuoxiID
		
		Insert Into CallCenter_Record(ZuoxiID,Type,Tel,StartDate,EndDate,FileName,CreateDate,DepartmentId,UserName,EName,TxtFileName,CompanyId)
		Values(@ZuoxiID,@Type,@Tel,@StartDate,@EndDate,@FileName,GetDate(),Isnull(@DepartmentId,-1),@UserName,@EName,@TxtFileName,@CompanyId)
	end
end
	RETURN
